from django.db import models

#导入时间域
from django.utils import timezone

#基类
class Base(models.Model):

	#创建时间
	create_time = models.DateTimeField(default=timezone.now,null=True)

	class Meta:
		abstract = True

class Role(models.Model):

    role_name = models.CharField("角色名称",max_length=32,unique=True)
    class Meta:
        db_table = "role"

# 权限表
class Access(models.Model):

	id = models.AutoField(primary_key=True)
	name = models.CharField(max_length=100, unique=True)

	class Meta:
		db_table = "access"

	def __str__(self):
		return self.name


#用户类
class User(Base):

	id = models.AutoField(primary_key=True)
	username = models.CharField(max_length=100, unique=True)
	password = models.CharField(max_length=200)
	phone = models.CharField(max_length=64)
	auth = models.ForeignKey(Access, on_delete=models.CASCADE)

	class Meta:
		db_table = "user"

	def __str__(self):
		return self.username





